/*
 * cpu.hpp
 *
 *  Created on: Jan 19, 2012
 *      Author: douglas
 */

#ifndef CPU_HPP_
#define CPU_HPP_

#include <playlib/defines.hpp>
#include <z80/z80.hpp>
#include <QtGui/QTextEdit>
#include <QtCore>
#include <string>
#include <iostream>
#include <stdio.h>
#include <string.h>


class cpu : public z80 {
private:
    //Size Memory for this CPU
	u8 Memory[4096];

	u32 programSize;
	bool runningProgram;

    QTextEdit *textEdit;

public:

	cpu(){
		programSize = 0;
		runningProgram = false;
	}

    cpu(QTextEdit *_textEdit){
        programSize = 0;
        runningProgram = false;
        textEdit = _textEdit;
    }

	void reset();

	virtual u8 read8(u16 address, int cycles);
	virtual void write8(u16 address, u8 data, int cycles);
	virtual void sync(int cycles);

	virtual void retCallback(int cycles);

	u32 run_program(const char *);
    u32 run_loaded_program();
	u32 load_program(const char *);


	void test_registers();
	void test_processor();
	void test_memory();
	void memoryDump(u16 start, u16 size);
	void registersDump();



};


#endif /* CPU_HPP_ */
